#include "gskprofilerprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkgltextureprivate.h"
-#include "gdk/gdkglcontextprivate.h"
#include <gdk/gdk.h>
#include <epoxy/gl.h>
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
-static void
-gsk_gl_driver_upload_texture (GskGLDriver *self,
- Texture *texture,
- int min_filter,
- int mag_filter,
- guchar *data)
-{
- if (self->bound_source_texture != texture)
- {
- g_critical ("You must bind the texture before initializing it.");
- return;
- }
-
- gsk_gl_driver_set_texture_parameters (self, min_filter, mag_filter);
- gdk_gl_context_upload_texture (self->gl_context,
- data,
- texture->width,
- texture->height,
- texture->width * 4,
- GL_TEXTURE_2D);
-
- texture->min_filter = min_filter;
- texture->mag_filter = mag_filter;
-
- if (texture->min_filter != GL_NEAREST)
- glGenerateMipmap (GL_TEXTURE_2D);
-}
-
static void
gsk_gl_driver_finalize (GObject *gobject)
{
int min_filter,
int mag_filter)
{
- const int stride = gdk_texture_get_width (texture) * 4;
Texture *t;
- guchar *texture_data = NULL;
+ cairo_surface_t *surface;
if (GDK_IS_GL_TEXTURE (texture))
{
/* In this case, we have to temporarily make the texture's context the current one,
* download its data into our context and then create a texture from it. */
gdk_gl_context_make_current (texture_context);
- texture_data = g_malloc (stride * gdk_texture_get_height (texture));
- gdk_texture_download (texture, texture_data, stride);
+ surface = gdk_texture_download_surface (texture);
gdk_gl_context_make_current (self->gl_context);
}
else
return t->texture_id;
}
- texture_data = g_malloc (stride * gdk_texture_get_height (texture));
- gdk_texture_download (texture, texture_data, stride);
+ surface = gdk_texture_download_surface (texture);
}
- g_assert (texture_data != NULL);
t = create_texture (self, gdk_texture_get_width (texture), gdk_texture_get_height (texture));
t->user = texture;
gsk_gl_driver_bind_source_texture (self, t->texture_id);
- gsk_gl_driver_upload_texture (self, t, min_filter, mag_filter, texture_data);
-
- g_free (texture_data);
+ gsk_gl_driver_init_texture_with_surface (self,
+ t->texture_id,
+ surface,
+ min_filter,
+ mag_filter);
+ cairo_surface_destroy (surface);
return t->texture_id;
}